const { Sequelize, Model } = require('sequelize')
const { sequelize } = require('../../core/db')
const ProCate = require('./ProCate')

class Product extends Model {}

Product.init({
  id: {
    type: Sequelize.INTEGER,
    autoIncrement: true,
    primaryKey: true
  },
  // proCateId: {
  //   type: Sequelize.INTEGER,
  //   // allowNull: false,
  //   references: {
  //     model: ProCate,
  //     key: 'id'
  //   }
  // },
  proName: Sequelize.STRING(30),
  content: Sequelize.STRING(6000),
  pic: Sequelize.STRING(200), 
  isRecommend: Sequelize.INTEGER,
  orderNum: {
    type: Sequelize.INTEGER,
    defaultValue: 1
  }
}, {
  sequelize
})

ProCate.hasMany(Product, {
  constraints: false
})
Product.belongsTo(ProCate, { // 会给Product表自动生成 ProCateId (模型名ProCate + id  并且是驼峰形式所以是 ProCateId)
  constraints: false
})

Product.sync({force: true}).then(() => {
  Product.bulkCreate([
    { ProCateId: 1, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 1 },
    { ProCateId: 2, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 2 },
    { ProCateId: 3, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 3 },
    { ProCateId: 1, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 4 },
    { ProCateId: 2, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 5 },
    { ProCateId: 1, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 6 },
    { ProCateId: 1, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 7 },
    { ProCateId: 1, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 8 },
    { ProCateId: 3, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 9 },
    { ProCateId: 1, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 10 },
    { ProCateId: 2, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 11 },
    { ProCateId: 3, proName: 'CONTI® SYNCHROBELT 标准同步带', content: `ss=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;
    &lt;span style=&quot;font-family:宋体;font-size:10.5000pt;&quot;&gt;2848&lt;/span&gt;&lt;span style=&quot;font-family:Calibri;font-size:10.5000pt;&quot;&gt;&lt;/span&gt; 
  &lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;`, pic: '/images/product/product.jpg', isRecommend: 1, orderNum: 12 }
  ])
})

module.exports = Product